package com.xbongbong.paas.enums;


import com.xbongbong.i18n.util.I18nMessageUtil;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @ClassName MobileModeTypeEnum
 * @Description 移动端首页专注模式
 * @Author mengna.Deng
 * @Date 2021/11/29 19:07
 * @Version 1.0
 */
public enum MobileFocusModeTypeEnum {
    /**
     * 工作模式
     */
    WORK(0,"work", "enum.mobileFocusModeType.name.work","0"),
    /**
     * 仪表盘模式
     */
    CATEGORY(1,"category", "enum.mobileFocusModeType.name.category","1"),
            ;

    public int code;
    public String alias;
    public String name;
    public String value;

    MobileFocusModeTypeEnum(Integer code, String alias, String name, String value){
        this.code = code;
        this.alias = alias;
        this.name = name;
        this.value = value;
    }

    public int getCode() {
        return code;
    }

    public String getAlias() {
        return alias;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getValue() {
        return value;
    }

    public static List<MobileFocusModeTypeEnum> getAllEnum(){
        List<MobileFocusModeTypeEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static MobileFocusModeTypeEnum getByAlias(String alias) {
        if(alias != null){
            for (MobileFocusModeTypeEnum cacheCode : values()) {
                if (Objects.equals(cacheCode.getAlias(), alias)) {
                    return cacheCode;
                }
            }
        }
        return null;
    }

    public static MobileFocusModeTypeEnum getByCode(Integer code) {
        for(MobileFocusModeTypeEnum mobileFocusModeTypeEnum: values()) {
            if(Objects.equals(mobileFocusModeTypeEnum.getCode(),code)) {
                return mobileFocusModeTypeEnum;
            }
        }
        return null;
    }

    public static MobileFocusModeTypeEnum getByValue(String value) {
        for(MobileFocusModeTypeEnum mobileFocusModeTypeEnum: values()) {
            if(Objects.equals(mobileFocusModeTypeEnum.getValue(),value)) {
                return mobileFocusModeTypeEnum;
            }
        }
        return null;
    }

    public static List<String> getAliasList() {
        List<String> alias = new ArrayList<>();
        for (MobileFocusModeTypeEnum cacheCode : values()) {
            alias.add(cacheCode.getAlias());
        }
        return alias;
    }
}
